package io.renren;

import org.junit.Test;

import java.util.Arrays;

public class Leetcode {

    public int specialArray(int[] nums) {
        Arrays.sort(nums);
        int index = 0;
        //i为特征值
        for(int i=0;i<=nums.length;i++){
            //length - index == i就成功
            while(index<nums.length && i>nums[index]){
                index++;
            }
            if(nums.length-index == i){
                return i;
            }
        }
        return -1;
    }

    @Test
    public void fun(){
    //[3,6,7,7,0]
        System.out.println(specialArray(new int[]{3,5}));
    }
}
